//
//  BJYFolderCell.m
//  JW_BasePorject
//
//  Created by JW on 2018/7/2.
//  Copyright © 2018年 JW. All rights reserved.
//

#import "BJYFolderCell.h"
#import "CacheGroupModel.h"
@interface BJYFolderCell ()

@property (nonatomic, strong)UIImageView *folderView;

@property (nonatomic, strong)UILabel *titleLabel;

@property (nonatomic, strong)UILabel *detailsLabel;


@end

@implementation BJYFolderCell

- (void)setGroupModel:(CacheGroupModel *)groupModel{
    _groupModel = groupModel;
    if (groupModel.cacheState == ZYDownloading) {
        self.folderView.image = [UIImage imageNamed:@"Downloading_folder"];
    }else if (groupModel.cacheState == ZYDownloaded){
        self.folderView.image = [UIImage imageNamed:@"Downloaded_folder"];
    }
    self.titleLabel.text = groupModel.showName;
    self.detailsLabel.text = [NSString stringWithFormat:@"%@个视频 | 大小:%@",groupModel.groupNumber,groupModel.groupTotalSize];
}

#pragma mark - 添加子控件
- (void)addChildViews{
    [self.contentView addSubview:self.folderView];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.detailsLabel];
    
}

+ (BJYFolderCell *)cellWithTableView:(UITableView *)tableView{
    static NSString *ident = @"BJYFolderCell";
    BJYFolderCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
    if (!cell) {
        cell = [[BJYFolderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ident];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
    
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addChildViews];
    }
    return  self;
}

- (UIImageView *)folderView{
    if (_folderView == nil) {
        _folderView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 30, 30)];
    }
    return _folderView;
}

- (UILabel *)titleLabel{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 10, SCREEN_WIDTH - 60, 20)];
        _titleLabel.font = [UIFont boldSystemFontOfSize:16];
        _titleLabel.numberOfLines = 2;
    }
    return _titleLabel;
}

- (UILabel *)detailsLabel{
    if (_detailsLabel == nil) {
        _detailsLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 30, SCREEN_WIDTH - 60, 10)];
        _detailsLabel.font = [UIFont systemFontOfSize:14];
        _detailsLabel.textColor = [UIColor grayColor];
    }
    return _detailsLabel;
    
}

//- (void)awakeFromNib {
//    [super awakeFromNib];
//    // Initialization code
//}
//
//- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
//    [super setSelected:selected animated:animated];
//
//    // Configure the view for the selected state
//}

@end
